package com.mwh.yuantu.dao;

import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mwh.yuantu.dao.mapper.HistoryInfoMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mwh.yuantu.entity.HistoryInfoEntity;

/**
 * (HistoryInfo)表数据库访问层
 *
 * @author maweihong
 * @since 2023-11-01 09:47:30
 */
@Service
public class HistoryInfoDao extends ServiceImpl<HistoryInfoMapper , HistoryInfoEntity> {

    @Autowired
	private HistoryInfoMapper historyInfoMapper;

    /**
     * 添加记录
     * @param historyInfo
     * @return
     */
    public int insert(HistoryInfoEntity historyInfo){
        return historyInfoMapper.insert(historyInfo);
    }

    /**
     * 删除记录
     * @param historyInfo
     * @return
     */
    public int delete(HistoryInfoEntity historyInfo){
        return historyInfoMapper.delete(historyInfo);
    }

    /**
     * 获取用户最新的5条历史记录
     * @param userId
     * @return
     */
    public List<Map<String, Object>> listHistory5(String userId){
        return historyInfoMapper.listHistory5(userId);
    }

    /**
     * 获取用户的历史记录列表
     * @param userId
     * @return
     */
    public List<Map<String, Object>> listHistory(String userId){
        return historyInfoMapper.listHistory(userId);
    }

    /**
     * 删除历史浏览记录表中的内容
     * @param userIdArr 用户id数组
     * @return
     */
    public int deleteByUserIdArr(@Param("userIdArr") String[] userIdArr){
        return historyInfoMapper.deleteByUserIdArr(userIdArr);
    }
}

